package cn.th.config;

import cn.th.filter.LoginCheckFilter;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;

@Configuration
public class MyInterceptorConfig implements WebMvcConfigurer {
    @Resource
    private LoginCheckFilter loginCheckFilter;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        InterceptorRegistration registration = registry.addInterceptor(loginCheckFilter);
        registration.addPathPatterns("/**")
                .excludePathPatterns(
                        //登录，退出，获取用户信息，文件的上传和显示在页面上
                        "/admin/login",
                        "/admin/logout",
                        "/admin/info",
                        "/common/**"
                );
    }
}
